package com.xyy.saas.payment.service;

import com.xyy.saas.payment.dao.model.BankBillJd0026QueryParam;
import com.xyy.saas.payment.dao.model.BankBillJd0027QueryParam;
import com.xyy.saas.payment.dao.model.BankBillJd0028QueryParam;
import com.xyy.saas.payment.dao.model.BankCardBindQueryParam;
import com.xyy.saas.payment.exception.PaymentException;
import com.xyy.saas.payment.manage.cores.dto.*;
import com.xyy.saas.payment.manage.cores.vo.BankCardBindLogVo;
import com.xyy.saas.payment.manage.cores.vo.ResultPageVo;
import com.xyy.saas.payment.manage.cores.vo.ResultVO;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.text.ParseException;
import java.util.List;

public interface JDPayService {

    /** *********************** 账单下载  ***************************/

    /**
     * 京东账单处理
     * 1、下载账单并解析
     * 2、上报数据给平安
     * retry：若处理成功会记入redis，防止重复处理，若传true，则不进行重复处理判断
     */
    String billDeal(String logPrefix, String date, boolean retry);

    String checkBill(String date);

    /**
     * 下载并解析账单
     */
    void downAndAnalysisBill(String logPrefix, String date) throws Exception;

    /**
     * 上报数据给平安
     */
    String submitBillPingan(String logPrefix, long analyTime, String merchantNo, String date) throws Exception;

    /** *********************** 账单查询  ***************************/
    /**
     * 0026账单查询
     */
    ResultPageVo<List<BankBillJd0026Dto>> queryByPage0026(BankBillJd0026QueryParam param) throws PaymentException;

    /**
     * 0027账单查询
     */
    ResultPageVo<List<BankBillJd0027Dto>> queryByPage0027(BankBillJd0027QueryParam param) throws PaymentException;

    /**
     * 0028账单查询
     */
    ResultPageVo<List<BankBillJd0028Dto>> queryByPage0028(BankBillJd0028QueryParam param) throws PaymentException;

    /** *********************** 绑卡信息  ***************************/
    /**
     * 查询绑卡日志记录
     */
    ResultVO<List<BankCardBindLogDto>> queryCardLog(BankCardBindLogVo param) throws IllegalAccessException;

    /**
     * 查询绑卡列表
     */
    ResultPageVo<List<BankCardBindDto>> queryCardPage(BankCardBindQueryParam param);

    /** *********************** 数据导出  ***************************/
    /**
     * 导出账单_0026
     */
    void export0026(BankBillJd0026QueryParam param, HttpServletRequest request, HttpServletResponse response) throws IOException, ParseException;

    /**
     * 导出账单_0027
     */
    void export0027(BankBillJd0027QueryParam param, HttpServletRequest request, HttpServletResponse response) throws IOException, ParseException;

    /**
     * 导出账单_0028
     */
    void export0028(BankBillJd0028QueryParam param, HttpServletRequest request, HttpServletResponse response) throws IOException, ParseException;

    /** *********************** 数据导出  ***************************/
    /**
     * 初始化 HttpServletResponse
     */
    void initHttpResponse(HttpServletResponse response, String downFileName) throws UnsupportedEncodingException;

    /**
     * 写入数据到 HttpServletResponse
     */
    void writeHttpResponse(HttpServletResponse response, OutputStream os, String data) throws IOException;

    /**
     * 关闭缓冲流
     */
    void closeStream(BufferedInputStream bis, OutputStream os);

}
